<!DOCTYPE html><html lang="zh-CN"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Git | VanKa</title><script src="https://cdn.bootcss.com/valine/1.4.4/Valine.min.js"></script><link rel="stylesheet" href="/vcb/css/arknights.css"><link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/highlight.js/10.1.2/styles/atom-one-dark-reasonable.min.css"><style>@font-face {
 font-family: BenderLight;
 src: local('Bender'), url("/vcb/font/BenderLight.ttf");
}
@font-face {
 font-family: 'JetBrains Mono';
 src: local('JetBrains Mono'), url('/vcb/font/JetBrainsMono-Regular.woff2') format('woff2');
}</style><meta name="generator" content="Hexo 5.4.0"><link rel="alternate" href="/vcb/atom.xml" title="VanKa" type="application/atom+xml">
</head><body><header><nav><a href="/vcb/">Home</a><a href="/vcb/archives/">Archives</a></nav></header><main><article><div id="post-bg"><div id="post-title"><h1>Git</h1><hr></div><div id="post-content"><h1 id="Git"><a href="#Git" class="headerlink" title="Git"></a>Git</h1><h3 id="常用命令"><a href="#常用命令" class="headerlink" title="常用命令"></a>常用命令</h3><table>
<thead>
<tr>
<th>命令</th>
<th>操作</th>
</tr>
</thead>
<tbody><tr>
<td>git init</td>
<td>初始化本地git环境</td>
</tr>
<tr>
<td>git clone XXX</td>
<td>克隆一份代码到本地仓库</td>
</tr>
<tr>
<td>git pull</td>
<td>把远程库的代码更新到工作台</td>
</tr>
<tr>
<td>git pull –rebase origin master</td>
<td>强制把远程库的代码跟新到当前分支上面</td>
</tr>
<tr>
<td>git fetch</td>
<td>把远程库的代码更新到本地库</td>
</tr>
<tr>
<td>git add .</td>
<td>把本地的修改加到stage中</td>
</tr>
<tr>
<td>git commit -m ‘comments here’</td>
<td>把stage中的修改提交到本地库</td>
</tr>
<tr>
<td>git push</td>
<td>把本地库的修改提交到远程库中</td>
</tr>
<tr>
<td>git branch -r/-a</td>
<td>查看远程分支/全部分支</td>
</tr>
<tr>
<td>git checkout master/branch</td>
<td>切换到某个分支</td>
</tr>
<tr>
<td>git checkout -b test</td>
<td>新建test分支</td>
</tr>
<tr>
<td>git checkout -d test</td>
<td>删除test分支</td>
</tr>
<tr>
<td>git merge master</td>
<td>假设当前在test分支上面，把master分支上的修改同步到test分支上</td>
</tr>
<tr>
<td>git merge tool</td>
<td>调用merge工具</td>
</tr>
<tr>
<td>git stash</td>
<td>把未完成的修改缓存到栈容器中</td>
</tr>
<tr>
<td>git stash list</td>
<td>查看所有的缓存</td>
</tr>
<tr>
<td>git stash pop</td>
<td>恢复本地分支到缓存状态</td>
</tr>
<tr>
<td>git blame someFile</td>
<td>查看某个文件的每一行的修改记录（）谁在什么时候修改的）</td>
</tr>
<tr>
<td>git status</td>
<td>查看当前分支有哪些修改</td>
</tr>
<tr>
<td>git log</td>
<td>查看当前分支上面的日志信息</td>
</tr>
<tr>
<td>git diff</td>
<td>查看当前没有add的内容</td>
</tr>
<tr>
<td>git diff –cache</td>
<td>查看已经add但是没有commit的内容</td>
</tr>
<tr>
<td>git diff HEAD</td>
<td>上面两个内容的合并</td>
</tr>
<tr>
<td>git reset –hard HEAD</td>
<td>撤销本地修改</td>
</tr>
<tr>
<td>echo $HOME</td>
<td>查看git config的HOME路径</td>
</tr>
<tr>
<td>export $HOME=/c/gitconfig</td>
<td>配置git config的HOME路径</td>
</tr>
</tbody></table>
<p>添加所有的到缓存区</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git add .</span><br></pre></td></tr></table></figure>

<p>提交到版本库</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git commit -m &quot;提交信息&quot;</span><br></pre></td></tr></table></figure>

<p>上传远程</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git push -u origin master</span><br></pre></td></tr></table></figure>



<h3 id="笔记"><a href="#笔记" class="headerlink" title="笔记"></a>笔记</h3><h5 id="git-绑定多个账号"><a href="#git-绑定多个账号" class="headerlink" title="git 绑定多个账号"></a>git 绑定多个账号</h5><blockquote>
<p>参考：<a target="_blank" rel="noopener" href="https://www.cnblogs.com/perferect/p/13432449.html">https://www.cnblogs.com/perferect/p/13432449.html</a></p>
</blockquote>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ssh-keygen -t rsa -C &quot;2395073039@qq.com&quot; -f .ssh/newfile</span><br></pre></td></tr></table></figure>





<p><a target="_blank" rel="noopener" href="https://www.uviewui.com/components/install.html">uViewUI</a></p>
<p><a target="_blank" rel="noopener" href="https://demo.color-ui.com/|">https://demo.color-ui.com/|</a></p>
<div id="paginator"></div></div><div id="post-footer"><hr><a href="/vcb/2021/10/10/Vue/">← Prev Vue</a><span style="color: #fe2"> | </span><a href="/vcb/2021/09/13/Linux/">Linux Next →</a><hr></div><div id="bottom-btn"><a id="to-index" href="#post-index" title="index">≡</a><a id="to-top" href="#post-title" title="to top">∧</a></div><div id="Valine"></div><script>new Valine({
 el: '#Valine'
 , appId: ''
 , appKey: ''
 , placeholder: '此条评论委托企鹅物流发送'
})</script></div></article><aside><div id="about"><a href="/vcb/" id="logo"><img src="https://ak.hypergryph.com/assets/index/images/ak/pc/faction/1.png" alt="Logo"></a><h1 id="Dr"><a href="/"> Dr.VanKa</a></h1><section id="total"><a id="total-archives" href="/vcb/archives"><span class="total-title">Archives Total:</span><span class="total-number">12</span></a><div id="total-tags"><span class="total-title">Tags:</span><span class="total-number">13</span></div><div id="total-categories"><span class="total-title">Categories:</span><span class="total-number">1</span></div></section></div><div id="aside-block"><h1>INDEX</h1><div id="post-index"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#Git"><span class="toc-number">1.</span> <span class="toc-text">Git</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4"><span class="toc-number">1.0.1.</span> <span class="toc-text">常用命令</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%AC%94%E8%AE%B0"><span class="toc-number">1.0.2.</span> <span class="toc-text">笔记</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#git-%E7%BB%91%E5%AE%9A%E5%A4%9A%E4%B8%AA%E8%B4%A6%E5%8F%B7"><span class="toc-number">1.0.2.0.1.</span> <span class="toc-text">git 绑定多个账号</span></a></li></ol></li></ol></li></ol></li></ol></li></ol></div></div><footer><nobr><span class="text-title">©</span><span class="text-content">1970 to 2020</span></nobr><wbr><nobr><span class="text-title">ICP</span><span class="text-content">——备案号——</span></nobr><wbr><wbr><nobr>published with&nbsp;<a target="_blank" rel="noopener" href="http://hexo.io">Hexo&nbsp;</a></nobr><wbr><nobr>Theme&nbsp;<a target="_blank" rel="noopener" href="https://github.com/Yue-plus/hexo-theme-arknights">Arknight&nbsp;</a></nobr><wbr><nobr>by&nbsp;<a target="_blank" rel="noopener" href="https://github.com/Yue-plus">Yue_plus</a></nobr></footer></aside></main><canvas id="canvas-dust"></canvas><script src="/vcb/js/arknights.js"></script><script src="https://cdn.bootcdn.net/ajax/libs/highlight.js/10.1.2/highlight.min.js"></script></body></html>